$(document).ready(function () {
    //  简单方式
    /*  new QRCode(document.getElementById('qrcode'), 'your content');*/
    /* 使用 API
     qrcode.clear();
     qrcode.makeCode('new content');
     */
    queryMyPartyAndMember();

// 设置参数方式
    var qrcode = new QRCode('qrcode', {//是id
        render: "canvas", //设置渲染方式，有table和canvas，使用canvas方式渲染性能相对来说比较好
        //text里放链接 eg:  http://192.168.1.102:8080/happy/EngineeringPower.html
        // text:"https://blog.csdn.net/qq_32283883/article/details/79450226",
            text: "http://192.168.43.46:8088/academic_system_web/HTML/student/party/PartyShowBy2wm.html?partyMemberAccount=20151000",
            //text: "http://192.168.43.209:63342/academic_system_web/HTML/student/party/PartyShowBy2wm.html?partyMemberAccount=20151000",
            //text: "http://192.168.0.15:63340/campus_information_portal_web/HTML/student/party/PartyShowBy2wm.html?partyMemberAccount=20151013",
        width: 200,
        height: 200,
        colorDark: '#000000',
        colorLight: '#ffffff',
        correctLevel: QRCode.CorrectLevel.L
    });
   // qrcode;
    $(".qr-btn").click(function () {
        $("#qrcode-modal").modal('show');
         $("canvas").show()//canvas画布
    })

//js里获取session里保存的值，例如:
    /*function getMyName(){
        var myName="<%=session.getAttribute("MYNAME")%>";
        alert(myName);
    }*/
//查询个人党组织信息和自己的入党情况
    function queryMyPartyAndMember() {
        $.ajax({
            url: "http://localhost:8080/partyApply/queryMyParty",
            type: "GET",
            async: true,
            data: "partyMemberAccount=" + 20151000,
            dataType: "json",
            success: function (data) {
              //  console.log("zkl-------"+data);
                console.log(data);
               //  console.log("wxy-------"+data.data);
                /* for(var key in data.data) {
                     alert("键：" + key + ",值 ：{姓名："+ data.data[key].partyFoundTime+"}");
                 }
                */
                /*  console.log(data.data.MyParty);*/
                var party = data.data.MyParty;
                var PartyMemberMe = data.data.PartyMemberMe;
                // alert(PartyMemberMe.applyDate);
                //党组织名称
                $("#partyName").val(party.partyName);
                //党组织概况
                $("#partyDescription").html("&nbsp;&nbsp;" + party.partyDescription);
                //党组织成立时间
                $("#partyFoundTime").val(party.partyFoundTime);
                //党员申请入党时间
                $("#stuApplyDate").val(PartyMemberMe.applyDate);
                if (PartyMemberMe.partyMemberType == 1) {
                    $("#stuPoli").val("积极分子");
                } else if (PartyMemberMe.partyMemberType == 2) {
                    $("#stuPoli").val("发展对象");
                } else if (PartyMemberMe.partyMemberType == 3) {
                    $("#stuPoli").val("中共预备党员");
                } else {
                    $("#stuPoli").val("中共党员");
                }
                var partyDescription = $("#partyDescription")
                //算出textarea的高度
                var textH = Math.ceil((partyDescription.val().length)/60) * 29;
                partyDescription.css("height", textH)
                //  alert("执行到底");

                // 获取图标数据
                var defaultdata = [
                    {value:0, name:'积极分子'},
                    {value:0, name:'发展对象'},
                    {value:0, name:'预备党员'},
                    {value:0, name:'正式党员'},
                ]
                    var typeStatics =  data.data.typeStatics;// data['data']['typeStatics']
                for(x in typeStatics){
                    var type = parseInt(typeStatics[x].party_member_type) - 1;
                    defaultdata[type].value = typeStatics[x].typesize
                }
                option.series[0].data = defaultdata;
                option.series[0].name = typeStatics[0].party_name;
                if (option && typeof option === "object") {
                    myChart.setOption(option, true);
                }
            }
        })
    }

    //zhaokailan
    var dom = document.getElementById("pie");
    var myChart = echarts.init(dom, 'wonderland');
    /*var app = {};*/
    option = null;
    option = {
        title : {
            text: '人员分布情况',
          //  subtext: '纯属虚构',
            x:'center'
        },
        tooltip : {
            trigger: 'item',
            formatter: "{a} <br/>{b} : {c}名 ({d}%)"
        },

        toolbox: {
            show : true,
            feature : {
                mark : {show: true},
                dataView : {show: true, readOnly: false},
                magicType : {
                    show: true,
                    type: ['pie', 'funnel']
                },
                restore : {show: true},
                saveAsImage : {show: true}
            }
        },
        calculable : true,
        series : [
            {
                name:'半径模式',
                type:'pie',
                radius : [15, 130],
                center : ['50%', '50%'],
                roseType : 'radius',
                label: {
                    normal: {
                        show: false
                    },
                    emphasis: {
                        show: true
                    }
                },
                lableLine: {
                    normal: {
                        show: false
                    },
                    emphasis: {
                        show: true
                    }
                },
                data:[

                ]
            }
        ]
    };
    ;

})



